/**
 *******************************************************************************
 * @file app_config.h
 * @author .ISS_AUTO (hudandan@issauto.com)
 * @date 2025-04-01
 *
 * @brief This file is for ARM Cortex™-M4F.
 *
 * @copyright Copyright (c) 2024 ISSAUTO TECH Co., Ltd. All rights reserved.
 *
 *******************************************************************************
 */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __APP_CONFIG_H_
#define __APP_CONFIG_H_

#ifdef USER_APP
    #define USER_EXT
#else
    #define USER_EXT  extern
#endif

#ifdef __cplusplus
extern "C" {
#endif



/** @addtogroup Project Information Configuration
  * @{
  */

#if defined(AK601)
#define PROJECT_TYPE_STR          "AK601"
#else
#define PROJECT_TYPE_STR          "(.>-<.)"
#endif


/** @note Only for macro check!
 * 📌 请检查当前项目类别宏定义，
 *    确保相关硬件配置符合当前需求!
 */
#if !defined(AK601)
#error "o.O"
#endif


/**
  * @}
  */


/* Exported Define -----------------------------------------------------------*/

/** @addtogroup Chips Driver Module Configuration
  * @{
  */

/**
  * @}
  */


/** @addtogroup Middleware Driver Layer Module Configuration(Only For Debug)
  * @{
  */

/**
  * @}
  */



/* Includes ------------------------------------------------------------------*/
#include "user_global.h"

#include "arm_math.h" //!< ARM-DSP库 Cortx-M4带FPU，硬件加速FFT
#include "arm_const_structs.h"


/* Exported types ------------------------------------------------------------*/

/** @addtogroup 数据类型定义
  * @{
  */
/**!* @brief  Project parameter structures definition
 */
typedef struct _Project_Global_TypeDef {
    __IO uint16_t Wake_Flag; //!< 唤醒标志
    __IO uint8_t  GO_SLEEP;  //!< 休眠标志
    __IO uint8_t  PRINTF_EN; //!< 打印使能位
} Project_Global_TypeDef;

/**
  * @}
  */


/* Exported Define -----------------------------------------------------------*/

/** @addtogroup Uart Driver Module Configuration
  * @{
  * #define UART_1_CFG_ENABLE             (0U) //!< UART1配置使能
  * #define UART_2_CFG_ENABLE             (0U) //!< UART2配置使能
  * #define UART_3_CFG_ENABLE             (0U) //!< UART3配置使能
  * #define UART_4_CFG_ENABLE             (0U) //!< UART4配置使能
  * #define UART_5_CFG_ENABLE             (0U) //!< UART5配置使能
  * #define UART_6_CFG_ENABLE             (0U) //!< UART6配置使能
  */

#define UART_1_CFG_ENABLE             (1U) //!< UART1配置使能
#define UART_2_CFG_ENABLE             (1U) //!< UART2配置使能
#define UART_3_CFG_ENABLE             (0U) //!< UART3配置使能
#define UART_5_CFG_ENABLE             (0U) //!< UART5配置使能
#define UART_6_CFG_ENABLE             (1U) //!< UART6配置使能

/*!< Uart Channel Config */
#define UART_CHANNEL_PRINTF           UART_CHANNEL_6
#define UART_IRQn_PRINTF              UART6_IRQn
#define UART_BAUDRATE_PRINTF          921600U

#define UART_CHANNEL_1                UART_CHANNEL_1
#define UART_IRQn_1                   USART1_IRQn
#define UART_BAUDRATE_1               115200U

#define UART_CHANNEL_2                UART_CHANNEL_2
#define UART_IRQn_2                   USART2_IRQn
#define UART_BAUDRATE_2               115200U


#define UART_CHANNEL_CLI              UART_CHANNEL_PRINTF
#define UART_IRQn_CLI                 UART_IRQn_PRINTF
#define UART_BAUDRATE_CLI             UART_BAUDRATE_PRINTF

/*!< Printf channel setting */
#define UARTx_PRINTF                  UART_CHANNEL_PRINTF

/**
  * @}
  */


/* Exported constants --------------------------------------------------------*/

/** @addtogroup System Configuration of User Applications
  * @{
  */

/** !< @note Project information */
#define MANUFACTURER                         "Issauto Inc."
#define FIRMWARE_VER_DATE                    (5)

//!< ISSAUTO命名方式: "FIRMWARE_VER_DATE(月份1-12)" + "FIRMWARE_VER_NUM(序号A-Z)"
#define HARDWARE_VERSION                     "AK601_4A"
#define FIRMWARE_VER_NUM                     (2 + 'A')

//!< 开发者命名方式:
#define FIRMWARE_REVISION_MAJOR              FIRMWARE_VER_DATE
#define FIRMWARE_REVISION_MINOR              0
#define FIRMWARE_REVISION_REVISION           0
#define FIRMWARE_REVISION_BUILD              0

#define FIRMWARE_REVISION_NUM                (FIRMWARE_REVISION_MAJOR << 24 | FIRMWARE_REVISION_MINOR << 16 | FIRMWARE_REVISION_REVISION << 8 | FIRMWARE_REVISION_BUILD)

/**
  * @}
  */


/* Exported macro ------------------------------------------------------------*/
#define ISS_MAX(a, b)                (((a) > (b)) ? (a) : (b))
#define ISS_MIN(a, b)                (((a) < (b)) ? (a) : (b))


/** @addtogroup ISS_ASSERT
  * @{
  */
// #define USER_ASSERT

#ifdef USER_ASSERT
#define ISS_ASSERT(x)   if (!(x)) { \
        printf("ISS_ASSERT(%s) at file %s:%d\r\n", #x, __FILE__, __LINE__);\
        while (1); \
    }
#else
#define ISS_ASSERT(x)    ((void)0)
#endif

#if (1)
/*!< malloc failed */
#define MALLOC_ASSERT(ptr)   if (!(ptr != NULL)) { \
        printf("ASSERT(%s) at file %s:%d\r\n", #ptr, __FILE__, __LINE__);\
        while (1); \
    }
#else
#define MALLOC_ASSERT(ptr)     { if (ptr == NULL) return -1; }

#endif

/**
  * @}
  */



/** @addtogroup GPIOx configure
  * @{
  * #define LED_ON()          GPIOC->PBSC = GPIO_PIN_8
  * #define LED_OFF()         GPIOC->PBC = GPIO_PIN_8
  */


/**
  * @}
  */



/** @addtogroup LabVIEW configure
  * @{
  */

#define COMM_CHANNEL_USB     UART_CHANNEL_PRINTF


/**
  * @}
  */




/** @addtogroup PVD configure
  * @{
  */
#if (PVD_ENABLE)
#define PWR_PVD_DISABLE()       *(__IO uint32_t*)CTRL_PVDEN_BB = (uint32_t)0
#endif

/**
  * @}
  */




/* Exported variables --------------------------------------------------------*/
USER_EXT Project_Global_TypeDef Project_Global;

#define app_log(M, ...)               \
    if (Project_Global.PRINTF_EN) {    \
        USER_PRINTF(M, ##__VA_ARGS__); \
    }


#ifdef __cplusplus
}
#endif

#endif /* __APP_CONFIG_H_ */

/* END OF FILE ---------------------------------------------------------------*/
